<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>本命星盘 | 个人星象分析</title>
    <style>
        /* 基础样式重置 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            /* 禁用移动端点击蒙层效果 */
            -webkit-tap-highlight-color: transparent;
            tap-highlight-color: transparent;
            outline: none;
        }

        /* 为可点击元素添加特定样式 */
        button,
        [class$="-btn"],
        .zodiac-sign,
        .chart-center,
        .planet,
        .house,
        a,
        [role="button"] {
            /* 禁用移动端点击蒙层效果 */
            -webkit-tap-highlight-color: transparent;
            tap-highlight-color: transparent;
            /* 防止文本选择 */
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            outline: none;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: #0a0e17;
            color: #ffffff;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 0;
            overflow-x: hidden;
            overflow-y: auto; /* 允许垂直滚动 */
        }
        
        /* 在iframe中显示时特殊处理 */
        body.in-iframe {
            padding: 20px;
        }

        /* 隐藏所有元素的滚动条但允许滚动 */
        html {
            scrollbar-width: none; /* Firefox */
            -ms-overflow-style: none; /* IE and Edge */
        }

        body {
            scrollbar-width: none; /* Firefox */
            -ms-overflow-style: none; /* IE and Edge */
        }

        /* Chrome, Safari and Opera */
        html::-webkit-scrollbar,
        body::-webkit-scrollbar {
            display: none;
        }

        /* 确保所有可滚动元素也隐藏滚动条 */
        * {
            scrollbar-width: none; /* Firefox */
        }

        *::-webkit-scrollbar {
            display: none; /* Chrome, Safari, Edge */
        }

        /* 页面标题 */
        header {
            text-align: center;
            margin-bottom: 30px;
            z-index: 10;
        }

        h1 {
            font-size: 2.5rem;
            margin-bottom: 10px;
            background: linear-gradient(90deg, #ff6b6b, #feca57, #48dbfb, #1dd1a1, #c8d6e5);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            background-size: 300% 300%;
            animation: gradient 15s ease infinite;
        }

        @keyframes gradient {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        .subtitle {
            color: #b2bec3;
            font-size: 1.1rem;
            max-width: 600px;
        }

        /* 出生信息表单 */
        .birth-info-form {
            background: rgba(17, 24, 39, 0.8);
            backdrop-filter: blur(10px);
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 30px;
            width: 90%;
            max-width: 600px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .form-row {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            margin-bottom: 15px;
        }

        .form-group {
            flex: 1;
            min-width: 200px;
        }

        .form-group label {
            display: block;
            margin-bottom: 5px;
            color: #b2bec3;
            font-size: 0.9rem;
        }

        .form-group input {
            width: 100%;
            padding: 10px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            background: rgba(30, 41, 59, 0.8);
            color: white;
            font-size: 1rem;
        }

        .form-group input:focus {
            outline: 2px solid rgba(59, 130, 246, 0.8);
            outline-offset: 2px;
        }

        .calculate-btn {
            width: 100%;
            padding: 12px;
            background: linear-gradient(90deg, #54a0ff, #00d2d3);
            border: none;
            border-radius: 8px;
            color: white;
            font-size: 1.1rem;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .calculate-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(59, 130, 246, 0.5);
        }

        /* 星盘容器 */
        .chart-container {
            position: relative;
            width: 90vw;
            max-width: 600px;
            height: 90vw;
            max-height: 600px;
            margin: 20px auto;
        }

        /* 星盘底座 */
        .chart-base {
            position: absolute;
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background: radial-gradient(circle, #1a237e 0%, #0d1117 100%);
            box-shadow: 0 0 50px rgba(33, 150, 243, 0.3);
            overflow: hidden;
        }

        /* 宫位环 */
        .houses-ring {
            position: absolute;
            width: 90%;
            height: 90%;
            top: 5%;
            left: 5%;
            border-radius: 50%;
        }

        /* 星座环 */
        .zodiac-ring {
            position: absolute;
            width: 80%;
            height: 80%;
            top: 10%;
            left: 10%;
            border-radius: 50%;
        }

        /* 行星环 */
        .planets-ring {
            position: absolute;
            width: 70%;
            height: 70%;
            top: 15%;
            left: 15%;
            border-radius: 50%;
        }

        /* 宫位扇区 */
        .house {
            position: absolute;
            width: 50%;
            height: 50%;
            top: 0;
            left: 50%;
            transform-origin: bottom left;
            border: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            align-items: flex-start;
            justify-content: center;
            padding-top: 10px;
        }

        .house-number {
            position: absolute;
            top: 15px;
            right: 15px;
            font-size: 0.9rem;
            font-weight: bold;
            color: #b2bec3;
        }

        /* 星座扇区 */
        .zodiac-sector {
            position: absolute;
            width: 50%;
            height: 50%;
            top: 0;
            left: 50%;
            transform-origin: bottom left;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .zodiac-sector-inner {
            position: relative;
            width: 100%;
            height: 100%;
            padding: 15% 10% 10% 10%;
        }

        .zodiac-sign {
            position: absolute;
            transform-origin: center;
            text-align: center;
            width: 50px;
            transition: all 0.3s ease;
            cursor: pointer;
        }

        .zodiac-sign:hover {
            transform: scale(1.1);
        }

        .zodiac-icon {
            font-size: 1.0rem;
            margin-bottom: -10px;
            text-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
            transform: translateY(20px);
        }

        /* 行星 */
        .planet {
            position: absolute;
            width: 25px;
            height: 25px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .planet:hover {
            transform: scale(1.2);
            box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
        }

        .planet-icon {
            font-size: 0.9rem;
            color: white;
        }

        /* 星盘中心 */
        .chart-center {
            position: absolute;
            width: 15%;
            height: 15%;
            top: 42.5%;
            left: 42.5%;
            border-radius: 50%;
            background: radial-gradient(circle, #ffd600 0%, #ff8f00 100%);
            box-shadow: 0 0 20px rgba(255, 193, 7, 0.8);
            z-index: 5;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .chart-center:hover {
            transform: scale(1.05);
            box-shadow: 0 0 25px rgba(255, 193, 7, 0.9);
        }

        .chart-center::after {
            content: '★';
            font-size: 1.5rem;
            color: white;
            text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
        }

        /* 方向标记 */
        .direction {
            position: absolute;
            z-index: 4;
            font-weight: bold;
            text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
        }

        .north {
            top: 2%;
            left: 50%;
            transform: translateX(-50%);
            color: #ff5252;
        }

        .east {
            top: 50%;
            right: 2%;
            transform: translateY(-50%);
            color: #4caf50;
        }

        .south {
            bottom: 2%;
            left: 50%;
            transform: translateX(-50%);
            color: #2196f3;
        }

        .west {
            top: 50%;
            left: 2%;
            transform: translateY(-50%);
            color: #9c27b0;
        }

        /* 信息面板 */
        .info-tabs {
            display: flex;
            gap: 10px;
            margin-bottom: 15px;
            overflow-x: auto;
            padding-bottom: 10px;
        }

        .info-tab {
            background: rgba(30, 41, 59, 0.8);
            border: 1px solid rgba(255, 255, 255, 0.1);
            color: white;
            padding: 8px 16px;
            border-radius: 20px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 0.9rem;
            white-space: nowrap;
        }

        .info-tab:hover {
            background: rgba(59, 130, 246, 0.5);
            transform: translateY(-2px);
        }

        .info-tab.active {
            background: rgba(59, 130, 246, 0.8);
            border-color: rgba(255, 255, 255, 0.5);
            box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
        }

        .info-content {
            background: rgba(17, 24, 39, 0.8);
            backdrop-filter: blur(10px);
            border-radius: 12px;
            padding: 20px;
            margin-top: 30px;
            width: 90%;
            max-width: 600px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .tab-content {
            display: none;
        }

        .tab-content.active {
            display: block;
        }

        .info-header {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            padding-bottom: 10px;
        }

        .info-icon {
            font-size: 2rem;
            margin-right: 15px;
        }

        .info-title {
            flex-grow: 1;
        }

        .info-name {
            font-size: 1.5rem;
            margin-bottom: 5px;
        }

        .info-details {
            color: #b2bec3;
            font-size: 0.9rem;
        }

        .info-text {
            font-size: 1rem;
            line-height: 1.6;
            color: #e9ecef;
            margin-bottom: 15px;
        }

        /* 控制按钮区域 */
        .controls-container {
            width: 90%;
            max-width: 600px;
            margin-top: 20px;
        }

        .controls {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
            margin: 20px 0;
        }

        .controls-row {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 10px;
        }

        .control-btn {
            background: rgba(30, 41, 59, 0.8);
            border: 1px solid rgba(255, 255, 255, 0.1);
            color: white;
            padding: 10px 14px;
            border-radius: 22px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 1.0rem;
            min-width: 80px;
        }

        .control-btn:hover {
            background: rgba(59, 130, 246, 0.5);
            transform: translateY(-2px);
        }

        /* 添加按钮点击时的选中效果 */
        .control-btn:active {
            transform: scale(0.95);
            background: rgba(59, 130, 246, 0.8);
        }

        .control-btn:focus {
            outline: 2px solid rgba(59, 130, 246, 0.8);
            outline-offset: 2px;
        }

        /* 添加选中状态样式 */
        .control-btn.selected {
            background: rgba(59, 130, 246, 0.8);
            border-color: rgba(255, 255, 255, 0.5);
            box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
        }

        .control-btn.reset {
            background: rgba(239, 68, 68, 0.3);
        }

        .control-btn.reset:active {
            background: rgba(239, 68, 68, 0.6);
        }

        .control-btn.reset.selected {
            background: rgba(239, 68, 68, 0.6);
            box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
        }

        /* 星星背景 */
        .stars {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
        }

        .star {
            position: absolute;
            background-color: white;
            border-radius: 50%;
            animation: twinkle 2s infinite alternate;
        }

        @keyframes twinkle {
            from { opacity: 0.3; }
            to { opacity: 1; }
        }

        /* 相位线 */
        .aspects {
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            z-index: 3;
            pointer-events: none;
        }

        .aspect-line {
            position: absolute;
            background: rgba(255, 255, 255, 0.2);
            transform-origin: center;
            pointer-events: none;
        }

        /* 响应式调整 */
        @media (max-width: 768px) {
            h1 {
                font-size: 2rem;
            }

            .subtitle {
                font-size: 1rem;
            }

            .birth-info-form {
                padding: 15px;
            }

            .form-row {
                flex-direction: column;
                gap: 10px;
            }

            .form-group {
                min-width: 100%;
            }

            .info-content {
                padding: 15px;
            }

            .info-name {
                font-size: 1.3rem;
            }

            .info-text {
                font-size: 0.9rem;
            }

            .control-btn {
                padding: 8px 14px;
                font-size: 1rem;
                min-width: 70px;
            }

            .planet {
                width: 20px;
                height: 20px;
            }

            .planet-icon {
                font-size: 0.8rem;
            }
        }

        @media (max-width: 480px) {
            .controls {
                gap: 8px;
            }

            .controls-row {
                gap: 8px;
            }
        }
    </style>
</head>
<body>
<!-- 星星背景 (将通过JS动态生成) -->
<div class="stars"></div>

<header>
    <h1>本命星盘</h1>
    <p class="subtitle">探索你出生时的天象，了解宇宙对你性格与命运的影响</p>
</header>

<!-- 出生信息表单 -->
<div class="birth-info-form" id="birthForm">
    <div class="form-row">
        <div class="form-group">
            <label for="birthDate">出生日期</label>
            <input type="date" id="birthDate">
        </div>
        <div class="form-group">
            <label for="birthTime">出生时间</label>
            <input type="time" id="birthTime" value="12:00">
        </div>
    </div>
    <div class="form-row">
        <div class="form-group">
            <label for="birthPlace">出生地点</label>
            <input type="text" id="birthPlace" placeholder="城市名称" value="北京">
        </div>
    </div>
    <button class="calculate-btn" id="calculateBtn">计算本命星盘</button>
</div>

<div class="chart-container">
    <!-- 星盘底座 -->
    <div class="chart-base"></div>

    <!-- 相位线 -->
    <div class="aspects" id="aspects"></div>

    <!-- 宫位环 -->
    <div class="houses-ring" id="housesRing">
        <!-- 宫位扇区将通过JS动态生成 -->
    </div>

    <!-- 星座环 -->
    <div class="zodiac-ring" id="zodiacRing">
        <!-- 星座扇区将通过JS动态生成 -->
    </div>

    <!-- 行星环 -->
    <div class="planets-ring" id="planetsRing">
        <!-- 行星将通过JS动态生成 -->
    </div>

    <!-- 方向标记 -->
    <div class="direction north">北</div>
    <div class="direction east">东</div>
    <div class="direction south">南</div>
    <div class="direction west">西</div>

    <!-- 星盘中心 -->
    <div class="chart-center" id="centerButton"></div>
</div>

<!-- 控制按钮 -->
<div class="controls-container">
    <div class="controls">
        <div class="controls-row">
            <button class="control-btn reset" id="resetBtn">重置</button>
            <button class="control-btn" id="rotateBtn">旋转星盘</button>
        </div>
    </div>
</div>

<!-- 信息面板 -->
<div class="info-content">
    <div class="info-tabs">
        <button class="info-tab active" data-tab="overview">星盘概览</button>
        <button class="info-tab" data-tab="planets">行星分析</button>
        <button class="info-tab" data-tab="houses">宫位解析</button>
        <button class="info-tab" data-tab="aspects">相位关系</button>
    </div>

    <div id="overview" class="tab-content active">
        <div class="info-header">
            <div class="info-icon">🌟</div>
            <div class="info-title">
                <div class="info-name">个人星盘分析</div>
                <div class="info-details" id="chartSummary">出生日期: 1990年1月1日 12:00 | 地点: 北京</div>
            </div>
        </div>
        <div class="info-text" id="overviewText">
            这是你的本命星盘分析。通过计算你出生时各行星的位置，我们可以深入了解你的性格特质、潜在能力和人生方向。星盘由12个星座、12个宫位和各大行星组成，它们之间的相互关系揭示了你的内在本质和外在表现。
        </div>
        <div class="info-text" id="keyFeatures">
            <strong>主要特征：</strong><br>
            - 太阳星座：摩羯座（你的核心本质和自我表达）<br>
            - 月亮星座：摩羯座（你的情感需求和内在情绪）<br>
            - 上升星座：摩羯座（你的外在形象和行为方式）<br>
            - 水星星座：摩羯座（你的思维方式和沟通习惯）<br>
            - 金星星座：射手座（你的爱情观和审美偏好）<br>
            - 火星星座：天蝎座（你的行动力和欲望表达方式）
        </div>
    </div>

    <div id="planets" class="tab-content">
        <div class="info-text">
            <strong>太阳：</strong>太阳代表你的核心本质和自我表达。太阳在摩羯座的你通常具有强烈的责任感和事业心。<br><br>
            <strong>月亮：</strong>月亮代表你的情感需求和内在情绪。月亮在摩羯座的你情绪稳定，重视安全感和实际价值。<br><br>
            <strong>水星：</strong>水星代表你的思维方式和沟通习惯。水星在摩羯座的你思维严谨，注重实际和效率。<br><br>
            <strong>金星：</strong>金星代表你的爱情观和审美偏好。金星在射手座的你追求自由和理想的爱情，讨厌束缚。<br><br>
            <strong>火星：</strong>火星代表你的行动力和欲望表达方式。火星在天蝎座的你具有强烈的意志力和激情。<br><br>
            <strong>木星：</strong>木星代表你的幸运和扩张领域。木星在天秤座的你善于社交，追求平衡与和谐。<br><br>
            <strong>土星：</strong>土星代表你的责任和限制。土星在狮子座的你有强烈的自我要求和领导欲望。<br><br>
            <strong>天王星：</strong>天王星代表你的创新和变革。天王星在天蝎座的你思想前卫，喜欢打破常规。<br><br>
            <strong>海王星：</strong>海王星代表你的梦想和直觉。海王星在射手座的你富有理想主义和哲学思考。<br><br>
            <strong>冥王星：</strong>冥王星代表你的转化和重生。冥王星在天秤座的你经历关系和价值观的深刻转变。
        </div>
    </div>

    <div id="houses" class="tab-content">
        <div class="info-text">
            <strong>第一宫：</strong>代表自我形象、性格和外在表现。<br><br>
            <strong>第二宫：</strong>代表财富、价值观和物质资源。<br><br>
            <strong>第三宫：</strong>代表沟通、学习和短途旅行。<br><br>
            <strong>第四宫：</strong>代表家庭、根源和内心安全感。<br><br>
            <strong>第五宫：</strong>代表创造力、爱情和娱乐。<br><br>
            <strong>第六宫：</strong>代表工作、健康和日常习惯。<br><br>
            <strong>第七宫：</strong>代表关系、合作和婚姻。<br><br>
            <strong>第八宫：</strong>代表转变、共享资源和深度连接。<br><br>
            <strong>第九宫：</strong>代表哲学、高等教育和长途旅行。<br><br>
            <strong>第十宫：</strong>代表事业、社会地位和公众形象。<br><br>
            <strong>第十一宫：</strong>代表朋友、群体和未来愿景。<br><br>
            <strong>第十二宫：</strong>代表潜意识、隐秘和灵性成长。<br><br>
        </div>
    </div>

    <div id="aspects" class="tab-content">
        <div class="info-text">
            <strong>合相 (0°)：</strong>行星能量融合，增强彼此的影响力。<br><br>
            <strong>对相 (180°)：</strong>行星能量对立，带来挑战和平衡的需要。<br><br>
            <strong>三分相 (120°)：</strong>行星能量和谐共振，带来天赋和机遇。<br><br>
            <strong>四分相 (90°)：</strong>行星能量紧张冲突，带来成长和突破的动力。<br><br>
            <strong>六分相 (60°)：</strong>行星能量温和互助，带来支持和机会。<br><br>
        </div>
    </div>
</div>

<script>
    // 星座数据 - 包含全部12个星座
    const zodiacSigns = [
        { name: "白羊座", symbol: "♈", color: "#ff6b6b", degrees: 0 },
        { name: "金牛座", symbol: "♉", color: "#feca57", degrees: 30 },
        { name: "双子座", symbol: "♊", color: "#48dbfb", degrees: 60 },
        { name: "巨蟹座", symbol: "♋", color: "#1dd1a1", degrees: 90 },
        { name: "狮子座", symbol: "♌", color: "#ff9f43", degrees: 120 },
        { name: "处女座", symbol: "♍", color: "#c8d6e5", degrees: 150 },
        { name: "天秤座", symbol: "♎", color: "#78e08f", degrees: 180 },
        { name: "天蝎座", symbol: "♏", color: "#ff6b81", degrees: 210 },
        { name: "射手座", symbol: "♐", color: "#f8a5c2", degrees: 240 },
        { name: "摩羯座", symbol: "♑", color: "#54a0ff", degrees: 270 },
        { name: "水瓶座", symbol: "♒", color: "#00d2d3", degrees: 300 },
        { name: "双鱼座", symbol: "♓", color: "#8e44ad", degrees: 330 }
    ];

    // 宫位数据
    const houses = [
        { number: 1, degrees: 0 },
        { number: 2, degrees: 30 },
        { number: 3, degrees: 60 },
        { number: 4, degrees: 90 },
        { number: 5, degrees: 120 },
        { number: 6, degrees: 150 },
        { number: 7, degrees: 180 },
        { number: 8, degrees: 210 },
        { number: 9, degrees: 240 },
        { number: 10, degrees: 270 },
        { number: 11, degrees: 300 },
        { number: 12, degrees: 330 }
    ];

    // 行星数据（示例位置，实际应用中需要根据出生信息计算）
    const planets = [
        { name: "太阳", symbol: "☉", degrees: 280, color: "#ffd700", size: 22 },
        { name: "月亮", symbol: "☽", degrees: 285, color: "#e0e0e0", size: 20 },
        { name: "水星", symbol: "☿", degrees: 275, color: "#a9a9a9", size: 18 },
        { name: "金星", symbol: "♀", degrees: 250, color: "#ff69b4", size: 19 },
        { name: "火星", symbol: "♂", degrees: 215, color: "#ff4500", size: 18 },
        { name: "木星", symbol: "♃", degrees: 195, color: "#98fb98", size: 24 },
        { name: "土星", symbol: "♄", degrees: 140, color: "#d2b48c", size: 21 },
        { name: "天王星", symbol: "♅", degrees: 220, color: "#00ced1", size: 20 },
        { name: "海王星", symbol: "♆", degrees: 245, color: "#8a2be2", size: 20 },
        { name: "冥王星", symbol: "♇", degrees: 190, color: "#bc8f8f", size: 18 },
        { name: "上升点", symbol: "↑", degrees: 0, color: "#ffffff", size: 20 },
        { name: "中天", symbol: "MC", degrees: 90, color: "#ff6347", size: 20 }
    ];

    // 相位数据（示例，实际应用中需要根据行星位置计算）
    const aspects = [
        { planet1: "太阳", planet2: "月亮", angle: 5, type: "合相" },
        { planet1: "太阳", planet2: "水星", angle: 5, type: "合相" },
        { planet1: "金星", planet2: "火星", angle: 35, type: "六分相" },
        { planet1: "火星", planet2: "土星", angle: 65, type: "六分相" },
        { planet1: "木星", planet2: "冥王星", angle: 5, type: "合相" }
    ];

    // 生成星座扇区
    function generateZodiacSigns() {
        const zodiacRing = document.getElementById('zodiacRing');

        zodiacSigns.forEach(sign => {
            const sector = document.createElement('div');
            sector.className = 'zodiac-sector';
            sector.style.transform = `rotate(${sign.degrees}deg)`;
            sector.style.backgroundColor = `${sign.color}20`; // 带透明度的背景色

            const inner = document.createElement('div');
            inner.className = 'zodiac-sector-inner';

            const signElement = document.createElement('div');
            signElement.className = 'zodiac-sign';
            signElement.setAttribute('data-sign', sign.name);
            signElement.style.transform = `translate(50%, 0%)`;

            const icon = document.createElement('div');
            icon.className = 'zodiac-icon';
            icon.style.color = sign.color;
            icon.textContent = sign.symbol;

            signElement.appendChild(icon);
            inner.appendChild(signElement);
            sector.appendChild(inner);
            zodiacRing.appendChild(sector);

            // 添加点击事件
            signElement.addEventListener('click', () => {
                showZodiacInfo(sign);
            });
        });
    }

    // 生成宫位扇区
    function generateHouses() {
        const housesRing = document.getElementById('housesRing');

        houses.forEach(house => {
            const sector = document.createElement('div');
            sector.className = 'house';
            sector.style.transform = `rotate(${house.degrees}deg)`;
            sector.setAttribute('data-house', house.number);

            const number = document.createElement('div');
            number.className = 'house-number';
            number.textContent = house.number;

            sector.appendChild(number);
            housesRing.appendChild(sector);

            // 添加点击事件
            sector.addEventListener('click', () => {
                showHouseInfo(house);
            });
        });
    }

    // 生成行星位置
    function generatePlanets() {
        const planetsRing = document.getElementById('planetsRing');
        const centerX = planetsRing.offsetWidth / 2;
        const centerY = planetsRing.offsetHeight / 2;
        const radius = centerX * 0.8; // 行星轨道半径

        // 等待DOM更新后获取正确的尺寸
        setTimeout(() => {
            planets.forEach(planet => {
                const angle = (planet.degrees - 90) * Math.PI / 180; // 转换为弧度并调整角度
                const x = centerX + radius * Math.cos(angle);
                const y = centerY + radius * Math.sin(angle);

                const planetElement = document.createElement('div');
                planetElement.className = 'planet';
                planetElement.style.left = `${x}px`;
                planetElement.style.top = `${y}px`;
                planetElement.style.width = `${planet.size}px`;
                planetElement.style.height = `${planet.size}px`;
                planetElement.style.backgroundColor = planet.color;
                planetElement.setAttribute('data-planet', planet.name);
                planetElement.setAttribute('data-degrees', planet.degrees);

                const icon = document.createElement('div');
                icon.className = 'planet-icon';
                icon.textContent = planet.symbol;

                planetElement.appendChild(icon);
                planetsRing.appendChild(planetElement);

                // 添加点击事件
                planetElement.addEventListener('click', () => {
                    showPlanetInfo(planet);
                });
            });

            // 生成相位线
            generateAspects();
        }, 100);
    }

    // 生成相位线
    function generateAspects() {
        const aspectsContainer = document.getElementById('aspects');
        const centerX = aspectsContainer.offsetWidth / 2;
        const centerY = aspectsContainer.offsetHeight / 2;
        const radius = centerX * 0.7; // 相位线半径

        setTimeout(() => {
            aspects.forEach(aspect => {
                const planet1 = planets.find(p => p.name === aspect.planet1);
                const planet2 = planets.find(p => p.name === aspect.planet2);

                if (planet1 && planet2) {
                    const angle1 = (planet1.degrees - 90) * Math.PI / 180;
                    const angle2 = (planet2.degrees - 90) * Math.PI / 180;

                    const x1 = centerX + radius * Math.cos(angle1);
                    const y1 = centerY + radius * Math.sin(angle1);
                    const x2 = centerX + radius * Math.cos(angle2);
                    const y2 = centerY + radius * Math.sin(angle2);

                    // 计算线条的长度和角度
                    const dx = x2 - x1;
                    const dy = y2 - y1;
                    const length = Math.sqrt(dx * dx + dy * dy);
                    const angle = Math.atan2(dy, dx) * 180 / Math.PI;

                    const line = document.createElement('div');
                    line.className = 'aspect-line';
                    line.style.width = `${length}px`;
                    line.style.height = '1px';
                    line.style.left = `${x1}px`;
                    line.style.top = `${y1}px`;
                    line.style.transform = `rotate(${angle}deg)`;
                    line.style.transformOrigin = '0 0';

                    // 根据相位类型设置不同的样式
                    if (aspect.type === '合相') {
                        line.style.backgroundColor = 'rgba(255, 215, 0, 0.5)';
                    } else if (aspect.type === '对相') {
                        line.style.backgroundColor = 'rgba(255, 99, 71, 0.5)';
                        line.style.height = '2px';
                    } else if (aspect.type === '三分相') {
                        line.style.backgroundColor = 'rgba(144, 238, 144, 0.5)';
                        line.style.height = '2px';
                    } else if (aspect.type === '四分相') {
                        line.style.backgroundColor = 'rgba(255, 182, 193, 0.5)';
                        line.style.height = '2px';
                    } else if (aspect.type === '六分相') {
                        line.style.backgroundColor = 'rgba(173, 216, 230, 0.5)';
                        line.style.height = '1px';
                    }

                    aspectsContainer.appendChild(line);
                }
            });
        }, 200);
    }

    // 显示星座信息
    function showZodiacInfo(sign) {
        // 实际应用中可以根据需要显示更详细的星座信息
        alert(`${sign.name} (${sign.symbol})`);
    }

    // 显示宫位信息
    function showHouseInfo(house) {
        // 实际应用中可以根据需要显示更详细的宫位信息
        alert(`第${house.number}宫`);
    }

    // 显示行星信息
    function showPlanetInfo(planet) {
        // 切换到行星选项卡
        switchTab('planets');
        
        // 实际应用中可以根据需要更新行星详情
        const planetDetails = document.getElementById('planets').querySelector('.info-text');
        planetDetails.innerHTML = `<strong>${planet.name} (${planet.symbol})</strong><br><br>位于 ${getZodiacByDegrees(planet.degrees).name} ${Math.round(planet.degrees % 30)} 度<br><br>`;
        
        // 添加行星具体描述
        let description = '';
        switch(planet.name) {
            case '太阳':
                description = '太阳代表你的核心本质和自我表达。它揭示了你最真实的身份和你希望在世界上展现的形象。';
                break;
            case '月亮':
                description = '月亮代表你的情感需求和内在情绪世界。它反映了你的安全感来源和情绪反应模式。';
                break;
            case '水星':
                description = '水星代表你的思维方式、沟通习惯和学习能力。它影响你如何处理信息和与他人交流。';
                break;
            case '金星':
                description = '金星代表你的爱情观、审美偏好和人际关系。它揭示了你如何表达爱与被爱。';
                break;
            case '火星':
                description = '火星代表你的行动力、欲望和能量表达。它反映了你的竞争意识和采取行动的方式。';
                break;
            case '木星':
                description = '木星代表你的幸运、扩张和成长领域。它揭示了你的机遇和乐观精神来源。';
                break;
            case '土星':
                description = '土星代表你的责任、限制和生活教训。它反映了你的耐心、毅力和面对挑战的方式。';
                break;
            case '天王星':
                description = '天王星代表创新、变革和独立。它揭示了你如何打破常规和追求自由。';
                break;
            case '海王星':
                description = '海王星代表梦想、直觉和灵性。它反映了你的想象力和对理想的追求。';
                break;
            case '冥王星':
                description = '冥王星代表转化、重生和力量。它揭示了你如何面对深刻的变化和个人成长。';
                break;
            case '上升点':
                description = '上升点代表你的外在形象和行为方式。它反映了他人对你的第一印象和你如何展现自己。';
                break;
            case '中天':
                description = '中天代表你的事业、社会地位和公众形象。它反映了你的职业目标和成就方向。';
                break;
        }
        
        planetDetails.innerHTML += description;
    }

    // 根据度数获取星座
    function getZodiacByDegrees(degrees) {
        const normalizedDegrees = degrees % 360;
        const index = Math.floor(normalizedDegrees / 30);
        return zodiacSigns[index];
    }

    // 切换信息选项卡
    function switchTab(tabId) {
        const tabs = document.querySelectorAll('.info-tab');
        const tabContents = document.querySelectorAll('.tab-content');

        tabs.forEach(tab => {
            tab.classList.remove('active');
            if (tab.getAttribute('data-tab') === tabId) {
                tab.classList.add('active');
            }
        });

        tabContents.forEach(content => {
            content.classList.remove('active');
            if (content.id === tabId) {
                content.classList.add('active');
            }
        });
    }

    // 旋转星盘
    function rotateChart(degrees) {
        const housesRing = document.getElementById('housesRing');
        const zodiacRing = document.getElementById('zodiacRing');
        const planetsRing = document.getElementById('planetsRing');
        const aspectsContainer = document.getElementById('aspects');

        // 清除现有的相位线
        while (aspectsContainer.firstChild) {
            aspectsContainer.removeChild(aspectsContainer.firstChild);
        }

        // 应用旋转
        housesRing.style.transform = `rotate(${degrees}deg)`;
        zodiacRing.style.transform = `rotate(${degrees}deg)`;
        planetsRing.style.transform = `rotate(${degrees}deg)`;

        // 重新生成相位线
        generateAspects();
    }

    // 计算本命星盘
    function calculateNatalChart() {
        const birthDate = document.getElementById('birthDate').value;
        const birthTime = document.getElementById('birthTime').value;
        const birthPlace = document.getElementById('birthPlace').value;

        // 显示计算中的提示
        alert('正在计算你的本命星盘...\n这是一个示例，实际应用中需要调用星盘计算API');

        // 更新星盘概览信息
        const dateObj = new Date(birthDate);
        const formattedDate = `${dateObj.getFullYear()}年${dateObj.getMonth() + 1}月${dateObj.getDate()}日 ${birthTime} | 地点: ${birthPlace}`;
        document.getElementById('chartSummary').textContent = formattedDate;

        // 这里应该调用星盘计算API获取实际的行星位置、宫位等信息
        // 为了演示，我们使用预设的数据
        
        // 清除现有的行星
        const planetsRing = document.getElementById('planetsRing');
        while (planetsRing.firstChild) {
            planetsRing.removeChild(planetsRing.firstChild);
        }

        // 重新生成行星
        generatePlanets();
    }

    // 生成星星背景
    function createStars() {
        const starsContainer = document.querySelector('.stars');
        const starCount = 150;

        for (let i = 0; i < starCount; i++) {
            const star = document.createElement('div');
            star.className = 'star';

            // 随机位置
            const x = Math.random() * 100;
            const y = Math.random() * 100;

            // 随机大小
            const size = Math.random() * 2 + 1;

            // 随机闪烁延迟
            const delay = Math.random() * 3;

            star.style.left = `${x}%`;
            star.style.top = `${y}%`;
            star.style.width = `${size}px`;
            star.style.height = `${size}px`;
            star.style.animationDelay = `${delay}s`;

            starsContainer.appendChild(star);
        }
    }

    // 优化滑动体验的函数
    function optimizeScrolling() {
        // 1. 通过CSS设置触摸行为，允许垂直滑动
        document.body.style.touchAction = 'pan-y';
        document.body.style.overscrollBehavior = 'contain';

        // 2. 定义变量用于触摸控制
        let startX = null;
        let startY = null;
        let isVerticalScrolling = false;
        const HORIZONTAL_THRESHOLD = 10; // 放宽水平滑动检测阈值
        const VERTICAL_MIN_DISTANCE = 5; // 垂直滑动最小距离

        // 触摸开始事件
        document.addEventListener('touchstart', (e) => {
            startX = e.touches[0].clientX;
            startY = e.touches[0].clientY;
            isVerticalScrolling = false;
        }, { passive: true });

        // 触摸移动事件 - 优化版，优先保证垂直滑动体验
        document.addEventListener('touchmove', (e) => {
            if (!startX || !startY) return;

            // 计算滑动距离
            const touchX = e.touches[0].clientX;
            const touchY = e.touches[0].clientY;
            const diffX = Math.abs(touchX - startX);
            const diffY = Math.abs(touchY - startY);

            // 确定是否为垂直滚动
            if (!isVerticalScrolling && diffY > VERTICAL_MIN_DISTANCE) {
                isVerticalScrolling = true;
            }

            // 只有当明显是水平滑动时才阻止
            if (!isVerticalScrolling && diffX > HORIZONTAL_THRESHOLD && diffX > diffY) {
                e.preventDefault();
            }
            // 如果已经确定为垂直滚动，则允许继续滚动
            // 这里不使用passive: false可以提高性能
        }, { passive: true });

        // 3. 手势处理 - 只在必要时阻止
        document.addEventListener('gesturestart', (e) => {
            e.preventDefault();
        }, { passive: false });

        // 4. 优化水平位置控制 - 减少过度干预
        let lastScrollTime = 0;
        const SCROLL_DELAY = 50; // 滚动事件防抖延迟

        window.addEventListener('scroll', () => {
            const now = Date.now();
            // 防抖处理，避免过于频繁地干预滚动
            if (now - lastScrollTime > SCROLL_DELAY && window.scrollX !== 0) {
                lastScrollTime = now;
                window.scrollTo(0, window.scrollY);
            }
        }, { passive: true });
    }

    // 添加事件监听器
    function addEventListeners() {
        // 计算按钮
        document.getElementById('calculateBtn').addEventListener('click', calculateNatalChart);

        // 重置按钮
        document.getElementById('resetBtn').addEventListener('click', () => {
            rotateChart(0);
        });

        // 旋转按钮
        document.getElementById('rotateBtn').addEventListener('click', () => {
            const randomRotation = Math.floor(Math.random() * 360);
            rotateChart(randomRotation);
        });

        // 中心按钮
        document.getElementById('centerButton').addEventListener('click', () => {
            const randomRotation = Math.floor(Math.random() * 360);
            rotateChart(randomRotation);
        });

        // 选项卡切换
        document.querySelectorAll('.info-tab').forEach(tab => {
            tab.addEventListener('click', () => {
                switchTab(tab.getAttribute('data-tab'));
            });
        });
    }

    // 自动设置今天的日期作为默认值
    function setDefaultDate() {
        const today = new Date();
        const year = today.getFullYear();
        const month = String(today.getMonth() + 1).padStart(2, '0');
        const day = String(today.getDate()).padStart(2, '0');
        document.getElementById('birthDate').value = `${year}-${month}-${day}`;
        document.getElementById('birthTime').value = '12:00';
    }

    // 页面加载完成后初始化
    window.addEventListener('load', () => {
        setDefaultDate();
        createStars();
        generateZodiacSigns();
        generateHouses();
        generatePlanets();
        addEventListeners();
        optimizeScrolling(); // 优化滑动体验
    });
</script>
</body>
</html>